<template>
  <a-config-provider update-at-scroll>
    <router-view></router-view>
    <div class="message-box">
      <div class="message-info" v-show="appStore.withdrawSecond > 0">
        <span style="color: red">{{ appStore.withdrawSecond }}秒</span>
        后推送到后台
        <icon-undo @click="handleCancel" />
      </div>
    </div>
    <template #loading>
      <img src="/static/images/loading.gif" class="loading-icon" />
    </template>
  </a-config-provider>
</template>

<script setup lang="ts">
import { useAppStore } from '@/stores'

defineOptions({ name: 'App' })
const appStore = useAppStore()
appStore.initTheme()
const handleCancel = () => {
  appStore.setWithdrawSecond(0)
  clearTimeout(appStore.withdrawTimer)
  appStore.setwithdrawTimer(null)
}
</script>

<style lang="scss" scoped>
.loading-icon {
  width: 30px;
}
.message-box {
  position: absolute;
  z-index: 999;
  right: 40px;
  bottom: 40px;
  .message-info {
    padding: 4px;
    background: #fff;
    box-shadow: 0 2px 4px 2px rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    .arco-icon {
      color: blue;
      cursor: pointer;
    }
  }
}
</style>
